// pages/user/user.js
var app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo: null,
    level: 0,
    signStatus: false,
    isGoIndex: false,
    iShidden: true,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.initApp()
  },

  /**
   * initApp
   */
  initApp: function() {
    let that = this,
        data1,data2
    wx.showLoading({
      mask: true,
      title: app.globalData.loadText,
    })
    app.getAccessToken(app.getPageUrl(getCurrentPages())).then(function (accessToken) {
      wx.request({
        url: app.globalData.hostAPI + '/v1/user/index?access_token=' + accessToken,
        success: res => {
          data1 = res.data.data
          if(res.data.status === 1) {
            that.setData({
              userInfo: data1
            })
            // wx.request({
            //   url: app.globalData.hostAPI + '/v1/signin/is-done?access_token=' + accessToken,
            //   success: res => {
            //     if(res.data.status === 1) {
            //         that.setData({
            //           signStatus: true
            //         })
            //     } else {
            //       that.setData({
            //         signStatus: false
            //       })
            //     }
            //   }
            // })
          }
          wx.hideLoading()
        }
      })
    })
  },
  
  onPullDownRefresh: function () {
    wx.showNavigationBarLoading()
    this.initApp()
    wx.hideNavigationBarLoading()
    wx.stopPullDownRefresh()
  },
})